package com.zhangyue.programmer.util;

import java.util.List;

public class Paged<T> {
    private int currentPage;
    private int totalPage;
    private int size = 10;
    private int totalSize;
    private List<T> list;

    public static <T> Paged<T> paging(int currentPage,int size,int totalSize,List<T> list){
        Paged<T> paged = new Paged<>();
        paged.currentPage = currentPage;
        paged.size = size;
        paged.totalSize = totalSize;
        paged.list = list;
        if(totalSize % size == 0){
            paged.totalPage = totalSize/size;
        }else {
            paged.totalPage = totalSize/size + 1;
        }
        return paged;
    }
    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
